﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    @V5.Html.Partial("User/_ChkUser")
    <title>@V5.Config.View["SiteTitle"]</title>
    <meta name="Keywords" content="网络购物，网上超市，网上购物，购物，网上商店，购物商城,购物网，超市网,世博会门票购买" />
    <meta name="Description" content="用鼠标逛超市，不用排队，方便实惠送上门，网上购物新生活。" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link type="text/css" rel="stylesheet" href="/@V5.Config.TemplatePath/css/index.css"/>
    <link type="text/css" rel="stylesheet" href="/@V5.Config.TemplatePath/css/product_detail.css"/> 
    <script src="/@V5.Config.TemplatePath/javascript/jquery.min.js" type="text/javascript"></script>
    <script src="/@V5.Config.TemplatePath/javascript/Comon.js" type="text/javascript" charset="UTF-8"></script> 
    <script src="/@V5.Config.TemplatePath/javascript/loading/loading_source.js" type="text/javascript" charset="UTF-8"></script>
    <link href="/@V5.Config.TemplatePath/javascript/dialog/css/custom-theme/dialog.css" rel="stylesheet" type="text/css"/>
    <script src="/@V5.Config.TemplatePath/javascript/dialog/js/jquery-ui-dialog.min.js" type="text/javascript"></script>
    @V5.Html.Partial("includes/tView")
</head>
<body>
    @*@V5.Html.Partial("includes/header")*@
    @{
        var user = (V5_Model.ModelGZUser)Session["isLogin"];
        Session["BuyerItemList"] = null;
        }
    <div class="wrap">
        @V5.Html.Partial("User/_Menu")
        <div class="right_content">
            <div class="crumb">
                <a class="home" href="/index.aspx" target="_blank">首页</a> > <span>个人中心</span>   &nbsp;&nbsp;&nbsp;<a href="/loginOut.aspx" style="background:none;color:Red;font-weight:bold">退出登录</a></div>
          <style>
              .personal_box h3 a
              {
                  margin-right:5px;
                  color:#b70000;
                  font-size:12px; 
               }
              
          </style>
            <div class="personal_box">
                <h3>快捷订单   <a href="javascript:;" id="btn_addProd">添加产品</a><a href="javascript:;" onclick="GoSubmit()">保存订单</a></h3>
                <div class="personal_detail">
                    <table width="90%" border="0" cellspacing="1" cellpadding="10" >
                        <tr style="height:30px"> 
                            <td>客户名称:</td>
                            <td colspan=3>@user.CustomName</td>  
                        </tr> 
                         <tr style="height:30px">
                            <td>订单备注:</td>
                            <td colspan=2>
                                <textarea style="width:550px;height:100px" id="txt_remarke"></textarea>
                            </td> 
                            <td valign="bottom" style=" background:white"><a href='javascript:;' class="ActiveCenterBg" id="btn_AddNews">活动中心</a></td>
                        </tr>
                    </table>
                </div>

                <div class="personal_detail">
                    <table width="100%" border="0" cellspacing="1" cellpadding="0" class="data" id="Item_List_Select">
                        <thead>
                            <tr> 
                                <th>
                                    名称
                                </th>
                                <th>
                                    单价
                                </th> 
                                 <th>
                                    数量
                                </th>
                                 <th>
                                    单位
                                </th>
                                 <th>
                                    金额
                                </th> 
                                <th>
                                    操作
                                </th>
                            </tr>
                        </thead> 
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="clearfix">
        </div>
        <div class="mt10">
        </div>
    </div>
   @* @V5.Html.Partial("includes/Footer")*@
    <!--回顶部 -->
    <div id="ProdDialog" style="display:none;">  
        <div id="showLoading">加载中...</div>
        <div id="showInfo" style="display:none; "></div>
    </div>

     <div id="NewsDialog" style="display:none;">  
        <div id="NewsLoading">加载中...</div>
        <div id="NewsInfo" style="display:none; "></div>
    </div>
</body>
</html> 
  <script>
      $("#txt_remarke").val("");
      $("#btn_addProd").bind("click", function () {
          ProdAction();
      });

      $("#btn_AddNews").bind("click", function () { 
          NewsAction();
      });

      $(".news_item_flow_select").live("click", function () {
          $("#txt_remarke").val($(this).attr("data-title"));
          $("#NewsDialog").dialog('close');
      });


      var ProdAction = function () {
          $('#ProdDialog').dialog({
              modal: true,
              autoOpen: true,
              width: 1000,
              height:400,
              title: '添加产品',
              open: function () {
                  getProdSelectPage("");
              },
              close: function () {
                  clearProdInfo(); 
              } 
          });
      }

      var NewsAction = function () {
          $('#NewsDialog').dialog({
              modal: true,
              autoOpen: true,
              width: 800,
              height: 400,
              title: '添加备注',
              open: function () {
                  clearNewsInfo();
                  $.ajax({
                      type: "Post",
                      url: "/index.aspx?t=GetNews",
                      success: function (result) {
                          $("#NewsLoading").hide();  
                          $("#NewsInfo").html(result).show();
                      },
                      complete: function () {
                          hideLoading();
                      }
                  });
              },
              close: function () {
                  clearNewsInfo();
              }
          });
      }

      var goSearch = function () {
          var key = $.trim($("#key").val());  
          getProdSelectPage(key); 
      }

      var getProdSelectPage = function (str) {
          clearProdInfo();
          $.ajax({
              type: "Post",
              url: "/index.aspx?t=user/AddProd",
              data: "s=" + str,
              success: function (result) {
                  $("#showLoading").hide(); 
                  $("#showInfo").html(result).show();
              },
              complete: function () {
                  hideLoading();
              }
          });
      }

      var clearProdInfo = function () {
          $("#showLoading").show();
          $("#showInfo").html("").hide();
          $("#plist .t").remove();
      }

      var clearNewsInfo = function () {
          $("#NewsLoading").show();
          $("#NewsInfo").html("").hide(); 
      }

      var SelectResult = function (str) {
          showLoading();
          $.ajax({
              type: "Post",
              url: "/index.aspx?t=user/MuilItemList",
              data: "s=" + str,
              success: function (result) {
                  $("#Item_List_Select tbody").append(result); 
                  $("#ProdDialog").dialog('close');
              },
              complete: function () {
                  hideLoading();
              }
          });

      }

      $(".del_sitem").live("click", function () {
          if (confirm("确认删除？")) {
              clearItem($(this).attr('data-id'));
          } 
      });


      var clearItem = function (id) {
          showLoading();
          $.ajax({
              type: "POST",
              url: "/ClearItem.aspx",
              data: "ID=" + id,
              success: function (res) {
                  if (res == "0") {
                      $("#si_" + id).remove();
                      msg("删除成功！");
                  }
                  else {
                      msg(res);
                  }
              },
              complete: function () {
                  hideLoading();
              }
          });
      }


      var GoSubmit = function () {
          var re = $("#txt_remarke").val();
          var url = "/SubmitBuyerList.aspx"; 
          showLoading();

          $.ajax({
              type: "Post",
              url: url,
              data: "c=" + re,
              success: function (result) {
                  if (result.indexOf("请先登录") > -1) {
                      msg("请先登录！");
                  }
                  else if (result.indexOf("请先购物") > -1) {
                      msg("订单库中没有产品信息！请刷新页面后重新选择");
                  }
                  else {
                      location.reload();
                      msg("添加成功！");
                      showLoading();

                  }

              },
              complete: function () {
                  hideLoading();
              }
          });
      }
  </script> 